package com.bdtop.dbl.server.request;

import com.bdtop.dbl.server.response.GetImgResponse;
import com.bdtop.dbl.thirdparty.asynchttp.HttpPostRequest;
import com.bdtop.dbl.thirdparty.asynchttp.RequestCallback;
import com.bdtop.dbl.utils.Constants;
import com.google.gson.Gson;

/**
 * 
  * @ClassName: GetImgRequest
  * @Description: TODO
  * @author: liyongqiang
  * @date:2014-10-30
 */
public class GetImgRequest extends HttpPostRequest {

    /**
     * @param callback
     */
    public GetImgRequest(RequestCallback callback) {
        super(callback);
        getRequestParams().add(Constants.COMMAND, Constants.CMD_DOWN_IMG);
    }

    public void setParams(String sign, String imgid) {
        getRequestParams().add(Constants.PARAM_LOGIN_SIGN, sign);
        getRequestParams().add(Constants.PARAM_IMGID, imgid);
        mHttpClient.setTimeout(100000);

    }

    @Override
    public Object parse(String responseString) {
        //DBLDebug.logd("GetImgRequest response = " + responseString);

        Gson gson = new Gson();
        GetImgResponse response = gson.fromJson(responseString, GetImgResponse.class);

        return response;
    }

    @Override
    protected String getUrl() {
        return Constants.SERVER_ADDRESS;
    }

}
